import request from '@/utils/request'
import { getToken } from '@/utils/auth'

export function addAgentApplication(level) {
  return request({
    url: '/AgentApplication/',
    method: 'post',
    data: {
      agentApplicationFile: level.agentApplicationFile,
      agentApplicationLevel: level.agentApplicationLevel,
      agentApplicationReason: level.agentApplicationReason,
      agentApplicationTitle: level.agentApplicationTitle,
      agentApplicationUserId: getToken(),
      agentApplicationStatus: 0
    }
  })
}

export function getAllAgentApplication() {
  return request({
    url: '/AgentApplication/all',
    method: 'get'
  })
}

export function getAgentApplicationById(agentApplicationId) {
  return request({
    url: '/AgentApplication/agentApplicationId',
    method: 'get',
    params: {
      agentApplicationId: agentApplicationId
    }
  })
}

export function changeStatus(agentApplicationId, updatedAgentApplicationStatus) {
  return request({
    url: '/AgentApplication/status',
    method: 'put',
    params: {
      agentApplicationId: agentApplicationId,
      updatedAgentApplicationStatus: updatedAgentApplicationStatus
    }
  })
}

export function getAgentApplicationByUserId() {
  return request({
    url: '/AgentApplication/userId',
    method: 'get',
    params: {
      userId: getToken()
    }
  })
}
